home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / viewers / polyview / polyvw31.lha / Polyview3.1 / new / physcam.c < prev    next >
C/C++ Source or Header  |  1993-06-23  |  1KB  |  35 lines

  1. /* $Header: /usr3/people/gbourhis/pv3/new/RCS/physcam.c,v 1.1 92/09/18 10:55:26 marca Exp $ */
  2.  
  3. #ifdef RCSLOG
  4. $Log:    physcam.c,v $
  5.  * Revision 1.1  92/09/18  10:55:26  marca
  6.  * Initial revision
  7.  * 
  8. #endif
  9.  
  10. /* Listing 8.4   A simple camera specification in terms of a physical camera */
  11. /*               with field of view control. */
  12.  
  13. /* FrameCamera(): give physical parameters for a camera.
  14.  * Parameters:
  15.  *    focallength: controls the width of the camera's field of view. 
  16.  *    framewidth: the width of the film image
  17.  *    frameheight: the height of the film image*/
  18. #include <ri.h>
  19. #include <math.h>
  20. #define min(a,b) ((a)<(b)?(a):(b))
  21. FrameCamera(focallength, framewidth, frameheight)
  22. float focallength, framewidth, frameheight;
  23. {
  24.     RtFloat fov;
  25.     /* A nonzero focal length is taken to be a "normal" lens */
  26.     if(focallength != 0.0) {
  27.         fov = 2 * atan((min(framewidth,frameheight)*.5)/focallength) *
  28.           180.0/3.14159;
  29.         RiProjection("perspective", 
  30.             RI_FOV, (RtPointer)&fov, RI_NULL);
  31.     } else 
  32.         RiProjection("orthographic", RI_NULL);    
  33.     RiFrameAspectRatio((RtFloat)(framewidth/frameheight));
  34. }
  35.